home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / FromTheMag / JW FLV MEDIA PLAYER 4.2 / mediaplayer.exe / player.swf / scripts / com / jeroenwijering / parsers / RSSParser.as < prev    next >
Text File  |  2008-11-04  |  3KB  |  90 lines

  1. package com.jeroenwijering.parsers
  2. {
  3.    import com.jeroenwijering.utils.Strings;
  4.    
  5.    public class RSSParser extends ObjectParser
  6.    {
  7.        
  8.       
  9.       public function RSSParser()
  10.       {
  11.          super();
  12.       }
  13.       
  14.       public static function parse(param1:XML) : Array
  15.       {
  16.          var _loc2_:Array = null;
  17.          var _loc3_:Object = null;
  18.          var _loc4_:XML = null;
  19.          var _loc5_:XML = null;
  20.          _loc2_ = new Array();
  21.          _loc3_ = new Object();
  22.          for each(_loc4_ in param1.children())
  23.          {
  24.             if(_loc4_.localName() == "channel")
  25.             {
  26.                for each(_loc5_ in _loc4_.children())
  27.                {
  28.                   if(_loc5_.name() == "item")
  29.                   {
  30.                      _loc3_ = RSSParser.parseItem(_loc5_);
  31.                   }
  32.                   if(_loc3_["type"] != undefined)
  33.                   {
  34.                      _loc2_.push(_loc3_);
  35.                   }
  36.                   _loc3_ = {};
  37.                }
  38.             }
  39.          }
  40.          return _loc2_;
  41.       }
  42.       
  43.       public static function parseItem(param1:XML) : Object
  44.       {
  45.          var _loc2_:Object = null;
  46.          var _loc3_:XML = null;
  47.          _loc2_ = new Object();
  48.          for each(_loc3_ in param1.children())
  49.          {
  50.             switch(_loc3_.localName())
  51.             {
  52.                case "duration":
  53.                   _loc2_["duration"] = Strings.seconds(_loc3_.text());
  54.                   break;
  55.                case "enclosure":
  56.                   _loc2_["file"] = _loc3_.@url.toString();
  57.                   _loc2_["type"] = _loc3_.@type.toString();
  58.                   break;
  59.                case "title":
  60.                   _loc2_["title"] = _loc3_.text().toString();
  61.                   break;
  62.                case "pubDate":
  63.                   _loc2_["date"] = _loc3_.text().toString();
  64.                   break;
  65.                case "keywords":
  66.                   _loc2_["tags"] = _loc3_.text().toString();
  67.                   break;
  68.                case "description":
  69.                   _loc2_["description"] = _loc3_.text().toString();
  70.                   break;
  71.                case "summary":
  72.                   _loc2_["description"] = _loc3_.text().toString();
  73.                   break;
  74.                case "link":
  75.                   _loc2_["link"] = _loc3_.text().toString();
  76.                   break;
  77.                case "author":
  78.                   _loc2_["author"] = _loc3_.text().toString();
  79.                   break;
  80.                case "group":
  81.                   _loc2_ = MediaParser.parseGroup(_loc3_,_loc2_);
  82.                   break;
  83.             }
  84.          }
  85.          _loc2_ = MediaParser.parseGroup(param1,_loc2_);
  86.          return ObjectParser.complete(_loc2_);
  87.       }
  88.    }
  89. }
  90.